<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
	<head>
		<style>
			h2 {
				font-size: 12px;
			}
			p {
				padding: 10px 20px;
				border: 1px solid #CCC;
				font-size: 10px;
			}
		</style>
	</head>
	<body id="body">
		<div id="searchFor"></div>
		<div id="results"></div>
		<script src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js"></script>
		<script src="Arrows.js?v=1"></script>
		<script src="jquery.arrows.js?v=1"></script>
		<script>
			// Notice the linear representation of an asynchronous program
			$.Arrows.InSequence(
				// Hit Twitter
				$.Arrows.Ajax({
					url: "http://search.twitter.com/search.json?q=dogs",
					dataType: "jsonp"
				}),
				// Take the result and return an object that can be fed
				//   into google
				function(result) {
					
					console.dir(result);
					var toSearch = result.results[0].from_user;
					
					$("#searchFor").text("Searching for \"" + toSearch + "\" ...");
				
					return {
						url: "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q="
							+ toSearch
					};
				},
				// Hit google
				$.Arrows.Ajax({
					dataType: "jsonp"
				}),
				// Log the result
				function(result) {
					var results = result.responseData.results;
					
					var div = $("#results");
					for (var i=0; i<results.length; i++) {
						div.append(
							$("<div class='result'></div>").append(
								$("<h2></h2>").html(results[i].title),
								$("<p></p>").html(results[i].content)
							)
						);
					}
				}
			).run();
		</script>
	</body>
</html>
